package com.ruoyi.labdata.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabRestrictedKinds;
import com.ruoyi.labdata.domain.LabRestrictedProperty;
import com.ruoyi.labdata.service.ILabRestrictedKindsService;
import com.ruoyi.labdata.service.ILabRestrictedPropertyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 管控品类型Controller
 * 
 * @author winner pan
 * @date 2022-02-16
 */
@RestController
@RequestMapping("/labdata/restrictedkinds")
public class LabRestrictedKindsController extends BaseController
{
    @Autowired
    private ILabRestrictedKindsService labRestrictedKindsService;
    
    @Autowired
    private ILabRestrictedPropertyService labRestrictedPropertyService;
    /**
     * 查询管控品类型列表
     */
    @PreAuthorize("@ss.hasPermi('labdata:restrictedkinds:query')")
    @GetMapping("/list")
    public TableDataInfo list(LabRestrictedKinds labRestrictedKinds)
    {
        startPage();
        List<LabRestrictedKinds> list = labRestrictedKindsService.selectLabRestrictedKindsList(labRestrictedKinds);
        return getDataTable(list);
    }

    /**
     * 导出管控品类型列表
     */
    //@PreAuthorize("@ss.hasPermi('labdata:restrictedkinds:export')")
    /*@Log(title = "管控品类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabRestrictedKinds labRestrictedKinds)
    {
        List<LabRestrictedKinds> list = labRestrictedKindsService.selectLabRestrictedKindsList(labRestrictedKinds);
        ExcelUtil<LabRestrictedKinds> util = new ExcelUtil<LabRestrictedKinds>(LabRestrictedKinds.class);
        return util.exportExcel(list, "restrictedkinds");
    }*/

    /**
     * 获取管控品类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('labdata:restrictedkinds:query')")
    @GetMapping(value = "/{kindsId}")
    public AjaxResult getInfo(@PathVariable("kindsId") Long kindsId)
    {
        return AjaxResult.success(labRestrictedKindsService.selectLabRestrictedKindsById(kindsId));
    }
    //labRestrictedPropertyService
    @GetMapping(value = "/allProperties")
    public AjaxResult getAllKinds(){
    	LabRestrictedProperty property = new LabRestrictedProperty();
    	property.setStatusOpt(Long.valueOf(1));
        return AjaxResult.success(labRestrictedPropertyService.selectLabRestrictedPropertyList(property));
    }
    /**
     * 新增管控品类型
     */
    @PreAuthorize("@ss.hasPermi('labdata:restrictedkinds:edit')")
    @Log(title = "管控品类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabRestrictedKinds labRestrictedKinds)
    {
        return toAjax(labRestrictedKindsService.insertLabRestrictedKinds(labRestrictedKinds));
    }

    /**
     * 修改管控品类型
     */
    @PreAuthorize("@ss.hasPermi('labdata:restrictedkinds:edit')")
    @Log(title = "管控品类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabRestrictedKinds labRestrictedKinds)
    {
        return toAjax(labRestrictedKindsService.updateLabRestrictedKinds(labRestrictedKinds));
    }

    /**
     * 删除管控品类型
     */
    @PreAuthorize("@ss.hasPermi('labdata:restrictedkinds:edit')")
    @Log(title = "管控品类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{kindsIds}")
    public AjaxResult remove(@PathVariable Long[] kindsIds)
    {
        return toAjax(labRestrictedKindsService.deleteLabRestrictedKindsByIds(kindsIds));
    }
}
